home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / gnu-c / rexx / gpp.rexx < prev   
OS/2 REXX Batch file  |  1993-11-01  |  3KB  |  113 lines

  1. /*rx
  2.  *  gpp.rexx --- Compile programs, treating .c files as C++.
  3.  *  Translated from /bin/sh script to ARexx for use under the AmigaOS.
  4.  *  By Loren J. Rittle (l-rittle@uiuc.edu)   Sun Mar  1 20:58:36 1992
  5.  *  Updated to work with any AmigaOS shell - Wed Mar  4 00:51:57 1992
  6.  *
  7.  *  In order to keep this file in usr:bin (instead of REXX: or S:)
  8.  *  you must:
  9.  *    ; If this file is not in usr:bin, then preform this step.
  10.  *    copy <this_file> usr:bin/gpp.rexx
  11.  *
  12.  *    ; Preform this step if your shell needs the script bit set
  13.  *    ; in order to recognize ARexx programs.
  14.  *    protect usr:bin/gpp.rexx +s
  15.  *
  16.  *    alias gpp usr:bin/gpp.rexx ;[and/or]
  17.  *    alias g++ usr:bin/gpp.rexx ;[and/or]
  18.  *    alias c++ usr:bin/gpp.rexx ;[whatever suits your fancy... :-]
  19.  */
  20.  
  21. /* This ARexx scripts assumes that you are also using the gcc.rexx
  22.  * stack setting wrapper script installed in usr:bin.  If this is
  23.  * not the case, change the next line to the correct path to gcc. */
  24. gcc_command = 'usr:bin/gcc.rexx'
  25.  
  26. /* NO GENERAL USER MODIFIABLE PARTS BELOW THIS COMMENT. */
  27.  
  28. if address() == 'REXX' then /* running from dumb (wrt ARexx) shell, better */
  29.   address 'COMMAND'         /* redirect where command get issued to */
  30.  
  31. newargs = ''
  32. quote = 'no'
  33. library = '-lg++'
  34. havefiles = 'no'
  35. speclang = 'no'
  36.  
  37. do i = 1 to words(arg(1))
  38.   arg = word(arg(1), i)
  39.   if quote == 'yes' then
  40.     do
  41.       newargs = newargs arg
  42.       quote = 'no'
  43.     end
  44.   else
  45.     do
  46.       quote = 'no'
  47.       select
  48.         when arg == '-nostdlib' then
  49.       do
  50.         /* Inhibit linking with -lg++. */
  51.         newargs = newargs arg
  52.         library = ''
  53.       end
  54.     when arg == '-Tdata' | arg == '-b' | arg == '-B' | arg == '-V' | ,
  55.          arg == '-D' | arg == '-U' | arg == '-o' | arg == '-e' | ,
  56.          arg == '-T' | arg == '-u' | arg == '-I' | arg == '-Y' | ,
  57.          arg == '-m' | arg == '-L' | arg == '-i' | arg == '-A'  then
  58.       do
  59.         newargs = newargs arg
  60.         /* these switches take following word as argument,
  61.            so don't treat it as a file name. */
  62.         quote = 'yes'
  63.       end
  64.     when arg == '-c' | arg == '-S' | arg == '-E' then
  65.       do
  66.         /* Don't specify libraries if we won't link,
  67.            since that would cause a warning. */
  68.         newargs = newargs arg
  69.         library = ''
  70.       end
  71.     when arg == '-xnone' then
  72.       do
  73.         newargs = newargs arg
  74.         speclang = 'no'
  75.       end
  76.     when compare(substr(arg,1,2),'-x') == 0 then
  77.       do
  78.         newargs = newargs arg
  79.         speclang = 'yes'
  80.       end
  81.     when compare(substr(arg,1,1),'-') == 0 then
  82.       /* Pass other options through; they don't need -x and aren't inputs. */
  83.       newargs = newargs arg
  84.     otherwise
  85.       do
  86.         havefiles = 'yes'
  87.         /* If file ends in .c or .i, put options around it.
  88.            But not if a specified -x option is currently active. */
  89.         if speclang == 'yes' then
  90.           newargs = newargs arg
  91.         else
  92.           do
  93.             if compare(substr(arg,length(arg)-1),'.c') == 0 then
  94.               newargs = newargs '-xc++' arg '-xnone'
  95.             else if compare(substr(arg,length(arg)-1),'.i') == 0 then
  96.               newargs = newargs '-xc++' arg '-xnone'
  97.             else
  98.               newargs = newargs arg
  99.           end
  100.       end
  101.       end
  102.     end
  103. end
  104.  
  105. if havefiles == 'no' then
  106.   do
  107.     parse source . . program_name .
  108.     say program_name ': no input files specified'
  109.     exit 1
  110.   end
  111.  
  112. gcc_command newargs library
  113.